package aviso.facade;

import aviso.entity.ScheduledMailRecord;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Stateless
public class ScheduledMailRecordFacade extends AbstractFacade<ScheduledMailRecord> {
    @PersistenceContext(unitName = "aviso")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public ScheduledMailRecordFacade() {
        super(ScheduledMailRecord.class);
    }
    
    public List <ScheduledMailRecord> getEmailsToSend(){
        return em.createQuery("select m from ScheduledMailRecord m where m.sent=false",
                ScheduledMailRecord.class).getResultList();
    }
}
